﻿<UserControl 
    x:Class="Smith.WPF.HtmlEditor.ColorPicker"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:local="clr-namespace:Smith.WPF.HtmlEditor">
	<UserControl.Resources>
		<local:ColorToBrushConverter x:Key="ColorConverter" />
		<Style x:Key="SelectorList" TargetType="{x:Type ListBox}">
			<Setter Property="BorderThickness" Value="0" />
			<Setter Property="HorizontalAlignment" Value="Left" />
			<Setter Property="SnapsToDevicePixels" Value="True" />
		</Style>
		<Style TargetType="{x:Type ListBoxItem}">
			<Setter Property="Margin" Value="3" />
            <Setter Property="Padding" Value="0" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
            <EventSetter Event="MouseLeftButtonUp" Handler="HandleSelect" />
		</Style>
		<DataTemplate DataType="{x:Type Color}">
            <Border x:Name="BdOut" Background="{Binding Converter={StaticResource ColorConverter}}"
                    BorderBrush="#E2E4E7" BorderThickness="1" Width="12" Height="12">
                <Border x:Name="BdInner" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" />
            </Border>
            <DataTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter TargetName="BdInner" Property="BorderBrush" Value="#FFE294" />
                    <Setter TargetName="BdOut" Property="BorderBrush" Value="#F29436" />
                </Trigger>
            </DataTemplate.Triggers>
        </DataTemplate>
	</UserControl.Resources>
    <Grid>
		<ListBox x:Name="StandardColors" Style="{StaticResource SelectorList}">
			<ListBox.ItemsPanel>
				<ItemsPanelTemplate>
					<WrapPanel Width="144" />
				</ItemsPanelTemplate>
			</ListBox.ItemsPanel>
		</ListBox>
	</Grid>
</UserControl>
